package main

import (
	"fmt"
	"time"
)

import (
	"GoLearnCase/pkg/caculte"
	"GoLearnCase/pkg/student"
	"GoLearnCase/pkg/teacher"
	"GoLearnCase/pkg/weekname"
)

//var teachers = teacher.GetTeacherInformation()

func main() {
	teachers := teacher.GetTeacherInformation()
	// 初始化一个 map
	students := make(map[string]student.Student)
	counter := caculte.NewCounter()
	for {
		fmt.Println("-------------------------------")
		fmt.Println("课堂练习功能列表：")
		fmt.Println("1.计算器功能")
		fmt.Println("2.星期功能")
		fmt.Println("3.学生信息输出")
		fmt.Println("4.学生信息录入")
		fmt.Println("5.教师信息展示")
		fmt.Println("6.教师信息更新")
		fmt.Println("7.closure计数器")
		fmt.Println("8.学生信息录入map")
		fmt.Println("9.学生信息录查找-切片")
		fmt.Println("10.显示当前系统时间")
		fmt.Println("11.退出")
		fmt.Println("-------------------------------")
		var input int
		fmt.Scanln(&input)
		switch input {
		case 1:
			fmt.Println("计算器功能-加法")
			fmt.Println("请输入第一个数字：")
			var a int
			fmt.Scanln(&a)
			fmt.Println("请输入第二个数字：")
			var b int
			fmt.Scanln(&b)
			fmt.Printf("a+b结果为：%d\n", caculte.AddNumber(a, b))
		case 2:
			fmt.Println("星期功能")
			weekname.WeekInformationShow()
		case 3:
			fmt.Println("学生信息输出")
			student.GetStudentInformation()
		case 4:
			fmt.Println("学生信息录入")
			students := student.InsertStudentInformation()
			fmt.Println(students)
		case 5:
			fmt.Println("教师信息展示")
			teacher.TeacherInformationShow(teachers)
			fmt.Printf("%T", teachers)
			fmt.Println()
		case 6:
			fmt.Println("教师信息更新")
			teacher.UpdateTeacherAge(&teachers, "11", 28)
			teacher.TeacherInformationShow(teachers)
		case 7:
			//fmt.Println(counter())
			fmt.Printf("累计：%d", counter())
			fmt.Println()
		case 8:
			fmt.Println("学生信息录入map")
			student.InsertStudentInformationMap(students)
			// 打印所有录入的学生信息
			for idKey, student := range students {
				fmt.Println("学生信息录:")
				fmt.Printf("学生 %s 的信息：\n", idKey)
				fmt.Printf("姓名：%s\n", student.Name)
				fmt.Printf("年龄：%d\n", student.Age)
				fmt.Printf("性别：%s\n", student.Sex)
				fmt.Printf("年级：%d\n", student.Grade)
				fmt.Printf("学校名称：%s\n", student.SchoolName)
				fmt.Printf("学校地址：%s\n", student.Address)
				fmt.Printf("学校类型：%s\n", student.SchoolType)
				fmt.Println("--------------------------")
			}
		case 9:
			// 输入多个学生信息
			studentNew := student.InsertStudentInformationIntoSlice()
			// 查找学生
			var searchName string
			fmt.Print("请输入要查找的学生姓名：")
			fmt.Scanln(&searchName)
			// 调用查找函数
			student.FindStudentByName(studentNew, searchName)
		case 10:
			// 显示当前系统时间
			currentTime := time.Now()
			fmt.Printf("当前系统时间：%s\n", currentTime.Format("2006-01-02 15:04:05"))
		case 11:
			fmt.Println("退出")
			return
		default:
			fmt.Println("无效选项，请重新选择！")
		}
	}
}
